package com.iflytek.jcy.supervise.clue.component.config;

import java.util.concurrent.ThreadPoolExecutor;

import com.iflytek.jcy.supervise.clue.common.util.ThreadPoolUtils;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author <a href=mailto:ktyi@iflytek.com>伊开堂</a>
 * @date 2022/9/19
 */
@Configuration
@EnableConfigurationProperties(ThreadPoolProperties.class)
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor commPool(ThreadPoolProperties poolProperties) {
        ThreadPoolProperties.PoolConfigInfo info = poolProperties.getCommon();
        return ThreadPoolUtils.createExecutor(info.getThreadSize(), info.getThreadNamePrefix(),
                                              info.getQueueCapacity());
    }

}
